<template>
    <div class="field-control field-check">
        <DatePicker :transfer="true" :disabled="disabled" :value="dateValue" @on-clear="dateClear" placement="bottom-end" @input="dateInput" :type="controlType" placeholder="选择日期"></DatePicker>
        <div class="field-message" v-show="!validate">{{message}}</div>
    </div>
</template>
<script>
import base from './base'
import Time from '@/common/time'
export default {
    extends: base,
    data() {
        return {
            formatStr: 'YYYY-MM-DD hh:mm:ss',
            controlType: 'datetime'
        }
    },
    computed: {
        dateValue() {
            if (this.value) {
                return Time.toTime(this.value, this.formatStr)
            } else {
                return null
            }
        }
    },
    methods: {
        dateInput(e) {
            var v = Time.toTs(e)
            this.valueInput(v)
        },
        dateClear(e) {
            this.valueInput(null)
        }
    }
}
</script>
<style lang="less">
.field-control .ivu-date-picker {
    width: 100%;
}
</style>
